import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/dashboard',
  //   children: [{
  //     path: 'dashboard',
  //     name: 'Dashboard',
  //     component: () => import('@/views/dashboard/index'),
  //     meta: { title: '首页', icon: 'dashboard' }
  //   }]
  // },
  {
    path: '/',
    component: Layout,
    redirect: '/user'
  },
  {
    path: '/user',
    component: Layout,
    children: [{
      path: '',
      name: 'User',
      component: () => import('@/views/user/index'),
      meta: { title: '用户', icon: 'el-icon-user' }
    }]
  },
  {
    path: '/merchant',
    component: Layout,
    children: [{
      path: '',
      name: 'Merchant',
      component: () => import('@/views/merchant/index'),
      meta: { title: '商户', icon: 'el-icon-user' }
    }]
  },
  {
    path: '/technician',
    component: Layout,
    children: [{
      path: '',
      name: 'Technician',
      component: () => import('@/views/technician/index'),
      meta: { title: '技师', icon: 'el-icon-user' }
    }]
  },
  {
    path: '/advertisement',
    component: Layout,
    children: [{
      path: '',
      name: 'Advertisement',
      component: () => import('@/views/advertisement/index'),
      meta: { title: '广告', icon: 'el-icon-monitor' }
    }]
  },
  {
    path: '/copywriting',
    component: Layout,
    children: [{
      path: '',
      name: 'Copywriting',
      component: () => import('@/views/copywriting/index'),
      meta: { title: '文案', icon: 'el-icon-postcard' }
    }]
  }
]

const createRouter = () => new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export default router
